package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdChannel;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 谢金成
 * @date 2024/4/10 14:32
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService channelService;

    @GetMapping("/channels")
    public ResponseResult findAll() {
        return channelService.findAll();
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto) {
        return channelService.listChannel(dto);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel adChannel) {
        return channelService.saveChannel(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return channelService.updateChannel(adChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return channelService.deleteChannel(id);
    }
}
